MoneyInterval<T>

Represents a sum of money to be exchanged during a given interval.

Syntax

public class MoneyInterval<T> : Interval<T> where T : IComparable<T>, IConvertible

Inheritance

Constructors

MoneyInterval

public MoneyInterval()

MoneyInterval

public MoneyInterval(decimal money, T value, IntervalType type)
Initializes a new instance of the class with the specified money amount, interval value, and type.

Parameters

  • money decimal: The amount of money represented by the given interval.
  • value T: The duration of the interval.
  • type IntervalType: The base unit that describes what the quantity of this interval references.

MoneyInterval

public MoneyInterval(T value, IntervalType type)
Initializes a new instance of the class with the specified interval value and type.

Parameters

  • value T: The duration of the interval.
  • type IntervalType: The base unit that describes what the quantity of this interval references.

Properties

Money

[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:$###,###,##0;($###,###,##0);$0}", NullDisplayText = "$0")]
public decimal Money { get; set; }
The amount of money represented by the given

Returns

decimal

Methods

PerDay

public override decimal PerDay()
Calculates the monetary amount per day based on this money interval.

Returns

decimal The amount of money per day as a decimal value.

PerDay

public override decimal PerDay(decimal quantity)
Calculates the total monetary amount per day based on this money interval and a quantity multiplier.

Parameters

  • quantity decimal: The quantity multiplier (e.g., hours worked, units sold).

Returns

decimal The total amount of money per day as a decimal value.

PerHour

public override decimal PerHour()
Calculates the monetary amount per hour based on this money interval.

Returns

decimal The amount of money per hour as a decimal value.

PerHour

public override decimal PerHour(decimal quantity)
Calculates the total monetary amount per hour based on this money interval and a quantity multiplier.

Parameters

  • quantity decimal: The quantity multiplier (e.g., hours worked, units sold).

Returns

decimal The total amount of money per hour as a decimal value.

PerMinute

public override decimal PerMinute()
Calculates the monetary amount per minute based on this money interval.

Returns

decimal The amount of money per minute as a decimal value.

PerMinute

public override decimal PerMinute(decimal quantity)
Calculates the total monetary amount per minute based on this money interval and a quantity multiplier.

Parameters

  • quantity decimal: The quantity multiplier (e.g., hours worked, units sold).

Returns

decimal The total amount of money per minute as a decimal value.

PerMonth

public override decimal PerMonth()
Calculates the monetary amount per month based on this money interval.

Returns

decimal The amount of money per month as a decimal value.

PerMonth

public override decimal PerMonth(decimal quantity)
Calculates the total monetary amount per month based on this money interval and a quantity multiplier.

Parameters

  • quantity decimal: The quantity multiplier (e.g., hours worked, units sold).

Returns

decimal The total amount of money per month as a decimal value.

PerWeek

public override decimal PerWeek()
Calculates the monetary amount per week based on this money interval.

Returns

decimal The amount of money per week as a decimal value.

PerWeek

public override decimal PerWeek(decimal quantity)
Calculates the total monetary amount per week based on this money interval and a quantity multiplier.

Parameters

  • quantity decimal: The quantity multiplier (e.g., hours worked, units sold).

Returns

decimal The total amount of money per week as a decimal value.

PerYear

public override decimal PerYear()
Calculates the monetary amount per year based on this money interval.

Returns

decimal The amount of money per year as a decimal value.

PerYear

public override decimal PerYear(decimal quantity)
Calculates the total monetary amount per year based on this money interval and a quantity multiplier.

Parameters

  • quantity decimal: The quantity multiplier (e.g., hours worked, units sold).

Returns

decimal The total amount of money per year as a decimal value.

ToString

public override string ToString()
Returns a string that represents the current object.

Returns

string A string that represents the current object.

ToString

public string ToString(int decimals)
Returns a string representation of the money interval with the specified number of decimal places for the currency value.

Parameters

  • decimals int: The number of decimal places to display for the currency value.

Returns

string A formatted string showing the money amount per interval period.

Remarks

This has been broken up to allow for conversions (for example, converting /monthinto/month into /day) to be self-contained. This should reduce duplication.